package com.fmi.cloud.app;

import android.app.Application;

import com.fmi.cloud.R;
import com.fmi.cloud.biz.FmUrl;
import com.fmi.cloud.util.SpUtil;
import com.fmi.cloud.util.VolleyHttpUtil;
import com.fmi.cloud.util.YcToastHelper;

import cn.jpush.android.api.JPushInterface;

/**
 * Application
 * Created by zv on 2017-12-3.
 */
public class YcApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        initToastHelper();
        initVolleyV3Helper();
        initSp();
        initJPush();
    }

    private void initJPush() {
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
    }

    /**
     * 最新的Volley HTTP Util,V3
     */
    private void initVolleyV3Helper() {
        VolleyHttpUtil.getInstance().setDebug(true);
        VolleyHttpUtil.getInstance().setServerURL(getHost());
        VolleyHttpUtil.getInstance().initVolleyHttpUtil(getApplicationContext());
    }


    private void initToastHelper() {
        YcToastHelper.getInstance().init(getApplicationContext());
    }

    private void initSp() {
        SpUtil.getInstance().init(getApplicationContext());
    }

    public String getHost() {
        return getApplicationContext().getString(R.string.host);
    }

    /**
     * operator=cloud房米云 | broker=fmkx房米快销
     */
    public String getAppType() {
        return getApplicationContext().getString(R.string.type);
    }


    /**
     * broker=fmkx房米快销
     */
    public static final String TYPE_BROKER = "broker";
    /**
     * operator=cloud房米云
     */
    public static final String TYPE_OPERATOR = "operator";

}
